package com.shanks.home.module.image;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

/**
 * 绘图
 * @author Shanks
 * @time 2014.05.28
 */
public class ShanksImageView extends View {

	public ShanksImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}
	
	@Override
	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
		
		// 把整张画布绘制成白色
		canvas.drawColor(Color.WHITE);
		
		// Paint
		Paint paint = new Paint();
		paint.setAntiAlias(true);	// 去锯齿
		paint.setColor(Color.BLUE);
		paint.setStyle(Paint.Style.STROKE);
		paint.setStrokeWidth(3);
		
		canvas.drawCircle(40, 30, 20, paint);
		
		// Path
		Path path = new Path();
		path.moveTo(10, 340);
		path.lineTo(70, 340);
		path.lineTo(40, 290);
		path.close();
		
		canvas.drawPath(path, paint);
	}
	
}